const { random } = require('./util/random')
const PIC_MAX = 10;

const createRandomArr = () => {
    return Array.from({ length: PIC_MAX }).map((item, index) => index + 1) || []
}
let randomArr = createRandomArr();
const getRamdomNum = () => {
    let randomArrLen = randomArr.length;
    if (!randomArrLen) {
        randomArr = createRandomArr();
    }
    // console.log("randomArrLen ========>", randomArrLen)
    let randomNum = random(0, randomArrLen - 1);
    // console.log("randomNum ========>", randomNum)
    // console.log("randomArr ========>", JSON.stringify(randomArr))

    let num = randomArr[randomNum]
    randomArr.splice(randomNum, 1)
    // console.log("updater ========>", JSON.stringify(randomArr))
    return num;
}
for (let i = 0; i < 10; i++) {
    console.log(getRamdomNum())
}